<div class="box box-solid no-margin box-show">
    <div class="box-body">
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>SKU</th>
                    <th width="10%">产品名称</th>
                    <th>备货数量</th>
                    <th>采购数量</th>
                    <th>采购单价</th>
                    <th>包材单价</th>
                    <th>采购金额</th>
                    <th>已收货数量</th>
                </tr>
                </thead>
                <tbody>
                @foreach($purchase->order_detail->sortBy('psku_id') as $detail)
                    <tr>
                        <td>{{ $detail->sku->psku_code }}</td>
                        <td>{{ $detail->sku->psku_cn }}</td>
                        <td>{{ $detail->apply_num }}</td>
                        <td>{{ $detail->order_num }}</td>
                        <td>{{ $detail->unit_price }}</td>
                        <td><a href="javascript:void(0)"
                               data-container="body"
                               data-toggle="popover"
                               data-placement="top"
                               data-html="true"
                               data-trigger="hover"
                               data-content="{{ $detail->pack_price_desc }}">{{ $detail->pack_price }}</a>
                        </td>
                        <td>{{ round(($detail->order_num ?: 0) * ($detail->unit_price ?: 0),3) }}</td>
                        <td>{{ $detail->rgoods_num }}</td>
                    </tr>
                    <tr>
                        <td colspan="8">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th width="20%">备货单号</th>
                                    <th width="20%">站点</th>
                                    <th width="20%">备货员</th>
                                    <th width="20%">备货数量</th>
                                    <th width="20%">下单数量</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($detail->stocking_detail as $item)
                                    <tr>
                                        <td>{{ $item->stocking_apply_detail->stocking_no ?? '' }}</td>
                                        <td>{{ $item->stocking_apply_detail->area->area ?? '' }}</td>
                                        <td>{{ \App\Util\User::getUsernameById($item->stocking_apply_detail->apply->seller_id ?? -1) }}</td>
                                        <td>{{ $item->apply_num }}</td>
                                        <td>{{ $item->order_num }}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
</div>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('[data-toggle="popover"]').popover();
    });
</script>
